#-*- coding: utf-8 -*-

template_head = '''<xmeml version="5">
    <sequence id="Subtitles-str">
    	<uuid>@@##{uuid}##@@</uuid>
    	<updatebehavior>add</updatebehavior>
    	<name>@@##{subtitle_name}##@@</name>
    	<duration>376</duration>
    	<rate>
    		<ntsc>FALSE</ntsc>
    		<timebase>25</timebase>
    	</rate>
    	<timecode>
    		<rate>
    			<ntsc>FALSE</ntsc>
    			<timebase>25</timebase>
    		</rate>
    		<string>00:00:00:00</string>
    		<frame>0</frame>
    		<source>source</source>
    		<displayformat>NDF</displayformat>
    	</timecode>
    	<in>-1</in>
    	<out>-1</out>
    	<media>
    		<video>
    			<format>
    				<samplecharacteristics>
    					<width>1920</width>
    					<height>1080</height>
    					<anamorphic>FALSE</anamorphic>
    					<pixelaspectratio>Square</pixelaspectratio>
    					<fielddominance>none</fielddominance>
    					<rate>
    						<ntsc>FALSE</ntsc>
    						<timebase>25</timebase>
    					</rate>
    					<colordepth>24</colordepth>
    					<codec>
    						<name>Apple ProRes 422 LT</name>
    						<appspecificdata>
    							<appname>Final Cut Pro</appname>
    							<appmanufacturer>Apple Inc.</appmanufacturer>
    							<appversion>7.0</appversion>
    							<data>
    								<qtcodec>
    									<codecname>Apple ProRes 422 LT</codecname>
    									<codectypename>Apple ProRes 422 LT</codectypename>
    									<codectypecode>apcs</codectypecode>
    									<codecvendorcode>appl</codecvendorcode>
    									<spatialquality>1023</spatialquality>
    									<temporalquality>0</temporalquality>
    									<keyframerate>0</keyframerate>
    									<datarate>0</datarate>
    								</qtcodec>
    							</data>
    						</appspecificdata>
    					</codec>
    				</samplecharacteristics>
    				<appspecificdata>
    					<appname>Final Cut Pro</appname>
    					<appmanufacturer>Apple Inc.</appmanufacturer>
    					<appversion>7.0</appversion>
    					<data>
    						<fcpimageprocessing>
    							<useyuv>TRUE</useyuv>
    							<usesuperwhite>FALSE</usesuperwhite>
    							<rendermode>YUV8BPP</rendermode>
    						</fcpimageprocessing>
    					</data>
    				</appspecificdata>
    			</format>
    			<track>
'''

template_tail = '''					<enabled>TRUE</enabled><locked>FALSE</locked>
				</track>
    		</video>
    		<audio>
    			<format>
    				<samplecharacteristics>
    					<depth>16</depth>
    					<samplerate>48000</samplerate>
    				</samplecharacteristics>
    			</format>
    			<outputs>
    				<group>
    					<index>1</index>
    					<numchannels>2</numchannels>
    					<downmix>0</downmix>
    					<channel>
    						<index>1</index>
    					</channel>
    					<channel>
    						<index>2</index>
    					</channel>
    				</group>
    			</outputs>
    			<in>-1</in>
    			<out>-1</out>
    			<track>
    				<enabled>TRUE</enabled>
    				<locked>FALSE</locked>
    				<outputchannelindex>1</outputchannelindex>
    			</track>
    			<track>
    				<enabled>TRUE</enabled>
    				<locked>FALSE</locked>
    				<outputchannelindex>2</outputchannelindex>
    			</track>
    			<track>
    				<enabled>TRUE</enabled>
    				<locked>FALSE</locked>
    				<outputchannelindex>1</outputchannelindex>
    			</track>
    			<track>
    				<enabled>TRUE</enabled>
    				<locked>FALSE</locked>
    				<outputchannelindex>2</outputchannelindex>
    			</track>
    			<filter>
    				<effect>
    					<name>Audio Levels</name>
    					<effectid>audiolevels</effectid>
    					<effectcategory>audiolevels</effectcategory>
    					<effecttype>audiolevels</effecttype>
    					<mediatype>audio</mediatype>
    					<parameter>
    						<name>Level</name>
    						<parameterid>level</parameterid>
    						<valuemin>0</valuemin>
    						<valuemax>3.98109</valuemax>
    						<value>1</value>
    					</parameter>
    				</effect>
    			</filter>
    		</audio>
    	</media>
    </sequence>
</xmeml>'''

template_generate = '''    				<generatoritem id="@@##{generatoritemId}##@@">
    					<name>@@##{strTitle}##@@</name>
    					<duration>3000</duration>
    					<rate>
    						<ntsc>FALSE</ntsc>
    						<timebase>25</timebase>
    					</rate>
    					<in>1375</in>
    					<out>1625</out>
    					<start>@@##{startFrame}##@@</start>
    					<end>@@##{endFrame}##@@</end>
    					<alphatype>black</alphatype>
    					<logginginfo>
    						<scene />
    						<shottake />
    						<lognote />
    						<good>FALSE</good>
    					</logginginfo>
    					<labels>
    						<label2 />
    					</labels>
    					<comments>
    						<mastercomment1 />
    						<mastercomment2 />
    						<mastercomment3 />
    						<mastercomment4 />
    					</comments>
    					<effect>
    						<name>空心字</name>
    						<effectid>Outline Text</effectid>
    						<effectcategory>文字</effectcategory>
    						<effecttype>generator</effecttype>
    						<mediatype>video</mediatype>
    						<parameter>
    							<parameterid>part1</parameterid>
    							<name>文本设置</name>
    							<value />
    						</parameter>
    						<parameter>
    							<parameterid>str</parameterid>
    							<name>文本</name>
    							<value>@@##{str}##@@</value>
    						</parameter>
    						<parameter>
    							<parameterid>font</parameterid>
    							<name>字体</name>
    							<value>Heiti SC</value>
    						</parameter>
    						<parameter>
    							<parameterid>style</parameterid>
    							<name>样式</name>
    							<valuemin>1</valuemin>
    							<valuemax>4</valuemax>
    							<valuelist>
    								<valueentry>
    									<name>普通</name>
    									<value>1</value>
    								</valueentry>
    								<valueentry>
    									<name>粗体</name>
    									<value>2</value>
    								</valueentry>
    								<valueentry>
    									<name>斜体</name>
    									<value>3</value>
    								</valueentry>
    								<valueentry>
    									<name>粗体/斜体</name>
    									<value>4</value>
    								</valueentry>
    							</valuelist>
    							<value>1</value>
    						</parameter>
    						<parameter>
    							<parameterid>align</parameterid>
    							<name>对齐</name>
    							<valuemin>1</valuemin>
    							<valuemax>3</valuemax>
    							<valuelist>
    								<valueentry>
    									<name>左</name>
    									<value>1</value>
    								</valueentry>
    								<valueentry>
    									<name>中</name>
    									<value>2</value>
    								</valueentry>
    								<valueentry>
    									<name>右</name>
    									<value>3</value>
    								</valueentry>
    							</valuelist>
    							<value>2</value>
    						</parameter>
    						<parameter>
    							<parameterid>size</parameterid>
    							<name>大小</name>
    							<valuemin>0</valuemin>
    							<valuemax>200</valuemax>
    							<value>19</value>
    						</parameter>
    						<parameter>
    							<parameterid>track</parameterid>
    							<name>字距</name>
    							<valuemin>0</valuemin>
    							<valuemax>100</valuemax>
    							<value>1</value>
    						</parameter>
    						<parameter>
    							<parameterid>lead</parameterid>
    							<name>行距</name>
    							<valuemin>-100</valuemin>
    							<valuemax>100</valuemax>
    							<value>0</value>
    						</parameter>
    						<parameter>
    							<parameterid>aspect</parameterid>
    							<name>宽高比</name>
    							<valuemin>0</valuemin>
    							<valuemax>4</valuemax>
    							<value>1</value>
    						</parameter>
    						<parameter>
    							<parameterid>linewidth</parameterid>
    							<name>线框宽度</name>
    							<valuemin>0</valuemin>
    							<valuemax>200</valuemax>
    							<value>50</value>
    						</parameter>
    						<parameter>
    							<parameterid>linesoft</parameterid>
    							<name>线框柔和度</name>
    							<valuemin>0</valuemin>
    							<valuemax>100</valuemax>
    							<value>5</value>
    						</parameter>
    						<parameter>
    							<parameterid>textopacity</parameterid>
    							<name>文本不透明度</name>
    							<valuemin>0</valuemin>
    							<valuemax>100</valuemax>
    							<value>100</value>
    						</parameter>
    						<parameter>
    							<parameterid>center</parameterid>
    							<name>中心</name>
    							<value>
    								<horiz>0</horiz>
    								<vert>0</vert>
    							</value>
    						</parameter>
    						<parameter>
    							<parameterid>textcolor</parameterid>
    							<name>文本颜色</name>
    							<value>
    								<alpha>255</alpha>
    								<red>255</red>
    								<green>255</green>
    								<blue>255</blue>
    							</value>
    						</parameter>
    						<parameter>
    							<parameterid>supertext</parameterid>
    							<name>文本图形</name>
    						</parameter>
    						<parameter>
    							<parameterid>linecolor</parameterid>
    							<name>线框颜色</name>
    							<value>
    								<alpha>255</alpha>
    								<red>0</red>
    								<green>0</green>
    								<blue>0</blue>
    							</value>
    						</parameter>
    						<parameter>
    							<parameterid>superline</parameterid>
    							<name>线框图形</name>
    						</parameter>
    						<parameter>
    							<parameterid>part2</parameterid>
    							<name>背景设置</name>
    							<value />
    						</parameter>
    						<parameter>
    							<parameterid>xscale</parameterid>
    							<name>水平宽度</name>
    							<valuemin>0</valuemin>
    							<valuemax>200</valuemax>
    							<value>0</value>
    						</parameter>
    						<parameter>
    							<parameterid>yscale</parameterid>
    							<name>V垂直高度</name>
    							<valuemin>0</valuemin>
    							<valuemax>200</valuemax>
    							<value>0</value>
    						</parameter>
    						<parameter>
    							<parameterid>xoffset</parameterid>
    							<name>水平位移</name>
    							<valuemin>-100</valuemin>
    							<valuemax>100</valuemax>
    							<value>0</value>
    						</parameter>
    						<parameter>
    							<parameterid>yoffset</parameterid>
    							<name>垂直位移</name>
    							<valuemin>-100</valuemin>
    							<valuemax>100</valuemax>
    							<value>0</value>
    						</parameter>
    						<parameter>
    							<parameterid>backsoft</parameterid>
    							<name>背景柔和度</name>
    							<valuemin>0</valuemin>
    							<valuemax>100</valuemax>
    							<value>0</value>
    						</parameter>
    						<parameter>
    							<parameterid>backopacity</parameterid>
    							<name>背景不透明度</name>
    							<valuemin>0</valuemin>
    							<valuemax>100</valuemax>
    							<value>50</value>
    						</parameter>
    						<parameter>
    							<parameterid>backcolor</parameterid>
    							<name>背景颜色</name>
    							<value>
    								<alpha>0</alpha>
    								<red>255</red>
    								<green>255</green>
    								<blue>255</blue>
    							</value>
    						</parameter>
    						<parameter>
    							<parameterid>superback</parameterid>
    							<name>背景图形</name>
    						</parameter>
    						<parameter>
    							<parameterid>crop</parameterid>
    							<name>裁剪</name>
    							<value>FALSE</value>
    						</parameter>
    						<parameter>
    							<parameterid>autokern</parameterid>
    							<name>自动微调字距</name>
    							<value>TRUE</value>
    						</parameter>
    					</effect>
    					<filter>
    						<effect>
    							<name>Basic Motion</name>
    							<effectid>basic</effectid>
    							<effectcategory>motion</effectcategory>
    							<effecttype>motion</effecttype>
    							<mediatype>video</mediatype>
    							<parameter>
    								<parameterid>scale</parameterid>
    								<name>Scale</name>
    								<valuemin>0</valuemin>
    								<valuemax>1000</valuemax>
    								<value>100</value>
    							</parameter>
    							<parameter>
    								<parameterid>rotation</parameterid>
    								<name>Rotation</name>
    								<valuemin>-8640</valuemin>
    								<valuemax>8640</valuemax>
    								<value>0</value>
    							</parameter>
    							<parameter>
    								<parameterid>center</parameterid>
    								<name>Center</name>
    								<value>
    									<horiz>0</horiz>
    									<vert>0</vert>
    								</value>
    							</parameter>
    							<parameter>
    								<parameterid>centerOffset</parameterid>
    								<name>Anchor Point</name>
    								<value>
    									<horiz>0</horiz>
    									<vert>0</vert>
    								</value>
    							</parameter>
    						</effect>
    					</filter>
    					<filter>
    						<enabled>TRUE</enabled>
    						<effect>
    							<name>Drop Shadow</name>
    							<effectid>dropshadow</effectid>
    							<effectcategory>motion</effectcategory>
    							<effecttype>motion</effecttype>
    							<mediatype>video</mediatype>
    							<parameter>
    								<parameterid>offset</parameterid>
    								<name>offset</name>
    								<valuemin>-100</valuemin>
    								<valuemax>100</valuemax>
    								<value>2</value>
    							</parameter>
    							<parameter>
    								<parameterid>angle</parameterid>
    								<name>angle</name>
    								<valuemin>-720</valuemin>
    								<valuemax>720</valuemax>
    								<value>135</value>
    							</parameter>
    							<parameter>
    								<parameterid>color</parameterid>
    								<name>color</name>
    								<value>
    									<alpha>0</alpha>
    									<red>0</red>
    									<green>0</green>
    									<blue>0</blue>
    								</value>
    							</parameter>
    							<parameter>
    								<parameterid>softness</parameterid>
    								<name>softness</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>10</value>
    							</parameter>
    							<parameter>
    								<parameterid>opacity</parameterid>
    								<name>opacity</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>50</value>
    							</parameter>
    						</effect>
    					</filter>
    					<filter>
    						<enabled>FALSE</enabled>
    						<effect>
    							<name>Motion Blur</name>
    							<effectid>motionblur</effectid>
    							<effectcategory>motion</effectcategory>
    							<effecttype>motion</effecttype>
    							<mediatype>video</mediatype>
    							<parameter>
    								<parameterid>duration</parameterid>
    								<name>% Blur</name>
    								<valuemin>0</valuemin>
    								<valuemax>1000</valuemax>
    								<value>500</value>
    							</parameter>
    							<parameter>
    								<parameterid>samples</parameterid>
    								<name>Samples</name>
    								<valuemin>1</valuemin>
    								<valuemax>16</valuemax>
    								<value>4</value>
    							</parameter>
    						</effect>
    					</filter>
    					<filter>
    						<effect>
    							<name>Crop</name>
    							<effectid>crop</effectid>
    							<effectcategory>motion</effectcategory>
    							<effecttype>motion</effecttype>
    							<mediatype>video</mediatype>
    							<parameter>
    								<parameterid>left</parameterid>
    								<name>left</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>0</value>
    							</parameter>
    							<parameter>
    								<parameterid>right</parameterid>
    								<name>right</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>0</value>
    							</parameter>
    							<parameter>
    								<parameterid>top</parameterid>
    								<name>top</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>0</value>
    							</parameter>
    							<parameter>
    								<parameterid>bottom</parameterid>
    								<name>bottom</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>0</value>
    							</parameter>
    							<parameter>
    								<parameterid>edgefeather</parameterid>
    								<name>edgefeather</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>0</value>
    							</parameter>
    						</effect>
    					</filter>
    					<filter>
    						<effect>
    							<name>Distort</name>
    							<effectid>deformation</effectid>
    							<effectcategory>motion</effectcategory>
    							<effecttype>motion</effecttype>
    							<mediatype>video</mediatype>
    							<parameter>
    								<parameterid>ulcorner</parameterid>
    								<name>Upper Left</name>
    								<value>
    									<horiz>-0.5</horiz>
    									<vert>-0.5</vert>
    								</value>
    							</parameter>
    							<parameter>
    								<parameterid>urcorner</parameterid>
    								<name>Upper Right</name>
    								<value>
    									<horiz>0.5</horiz>
    									<vert>-0.5</vert>
    								</value>
    							</parameter>
    							<parameter>
    								<parameterid>lrcorner</parameterid>
    								<name>Lower Right</name>
    								<value>
    									<horiz>0.5</horiz>
    									<vert>0.5</vert>
    								</value>
    							</parameter>
    							<parameter>
    								<parameterid>llcorner</parameterid>
    								<name>Lower Left</name>
    								<value>
    									<horiz>-0.5</horiz>
    									<vert>0.5</vert>
    								</value>
    							</parameter>
    							<parameter>
    								<parameterid>aspect</parameterid>
    								<name>Aspect</name>
    								<valuemin>-10000</valuemin>
    								<valuemax>10000</valuemax>
    								<value>0</value>
    							</parameter>
    						</effect>
    					</filter>
    					<filter>
    						<effect>
    							<name>Opacity</name>
    							<effectid>opacity</effectid>
    							<effectcategory>motion</effectcategory>
    							<effecttype>motion</effecttype>
    							<mediatype>video</mediatype>
    							<parameter>
    								<parameterid>opacity</parameterid>
    								<name>opacity</name>
    								<valuemin>0</valuemin>
    								<valuemax>100</valuemax>
    								<value>100</value>
    							</parameter>
    						</effect>
    					</filter>
    					<sourcetrack>
    						<mediatype>video</mediatype>
    					</sourcetrack>
    					<itemhistory>
    						<uuid>@@##{uuid}##@@</uuid>
    					</itemhistory>
    				</generatoritem>
'''